package com.aizuda.boot.modules.message;

import com.aizuda.boot.modules.business.job.FilingJob;
import com.aizuda.boot.modules.business.job.NumberJob;
import com.aizuda.boot.modules.business.job.PerformanceJob;
import com.aizuda.boot.modules.business.job.PermissionJob;
import com.aizuda.boot.modules.common.MessageEvent;
import com.aizuda.boot.modules.system.entity.enums.BusinessType;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationEventPublisher;

import java.util.List;

/**
 * @Author sangyirong
 * @ClassName Message
 * @Version 1.0
 * @Date 2025/7/9 10:49
 */
@SpringBootTest
public class Message {

    @Resource
    private ApplicationEventPublisher applicationEventPublisher;

    @Resource
    private FilingJob filingJob;

    @Resource
    private PerformanceJob performanceJob;

    @Resource
    private NumberJob numberJob;

    @Resource
    private PermissionJob permissionJob;

    @Test
    public void sendMessageTest(){
        MessageEvent messageEvent = new MessageEvent();
        messageEvent.setTitle("测试发送一个消息");
        messageEvent.setContent(messageEvent.getTitle());
        messageEvent.setCreateId(0L);
        messageEvent.setCreateBy("系统");
        messageEvent.setCategory(2);
        messageEvent.setBusinessId(1940683071462633474L);
        messageEvent.setBusinessType(BusinessType.other.name());
        messageEvent.setUserIds(List.of(1940683071462633474L));
        applicationEventPublisher.publishEvent(messageEvent);
    }

    /**
     * 测试发送归档提醒
     */
    @Test
    public void test(){
        filingJob.sendFilingMessage();
    }

    /**
     * 测试发送履约提醒
     */
    @Test
    public void testPerformance(){
        performanceJob.sendPerformanceMessage();
    }

    @Test
    public void testNumber(){
        numberJob.resetNumberSequenceHandler();
    }

    @Test
    public void testPermission(){
        permissionJob.updatePermissionStatus();
    }
}
